package club.haomoon.core.validator;

import club.haomoon.core.validator.annotation.IDMust;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
 * -------------------------
 * @Description: 验证主键ID参数
 * @Author: Wangjianwei
 * @Date: 2025/02/12 16:37
 * -------------------------
 */
public class IDMustValidator implements ConstraintValidator<IDMust, Integer> {

    @Override
    public void initialize(IDMust constraintAnnotation) {
        ConstraintValidator.super.initialize(constraintAnnotation);
    }

    @Override
    public boolean isValid(Integer value, ConstraintValidatorContext constraintValidatorContext) {
        return value != null && value > 0;
    }

}
